Skip to content

Comments

feat: 유저픽 게시글 저장 기능 구현#98

Merged
hisonghy merged 3 commits intodevelopfrom
feature/save-post-94
Apr 18, 2025
Merged

feat: 유저픽 게시글 저장 기능 구현#98
hisonghy merged 3 commits intodevelopfrom
feature/save-post-94

Conversation

@hisonghy
Copy link
Member

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 유저픽 게시글 저장하는 로직 구현했습니다
  • 유저픽 게시글 저장할 때 유저픽 게시글 이미지, 게시글 속 상품 목록, 각 상품별 이미지도 함께 등록되도록 구현했습니다
  • s3 이미지 업로드할 때 만약 예외, 에러가 발생하면, 트랜잭션 rollback 으로 이미 업로드된 이미지를 삭제하도록 구현했습니다
  • PostJpaEntity 에서 content 타입에 @Lob 어노테이션을 사용해 실제 저장될 때 TEXT, String 형태가 아닌 바이너리 데이터 형태로 저장되는 이슈가 발생해서 해당 어노테이션을 제거했습니다
  • 상품은 개별 하나의 이미지과 매핑이 가능하기 때문에 각 상품별 요청 데이터에 imageIndex 라는 필드를 두고 List<MultipartFile> productImageFiles 에서 각 상품의 이미지 인덱스를 받도록 구현하고 상품 이미지 목록과 상품 정보 목록을 비교해 검증하는 로직을 추가해 이미지가 잘못 매핑되지 않도록 했습니다

🔍 참고사항

🔥 PostgreSQL 특이점
PostgreSQL은 TEXT 타입이 기본적으로 "대용량 문자열"을 잘 처리하기 때문에
@Lob 없이도 충분하고,
@Lob이 들어가면 JPA 구현체가 이를 Binary Large Object (BLOB)으로 잘못 해석할 수 있어.

그 결과:

실제 저장: 바이너리로 저장

DB 툴에서 보이는 값: 바이트 길이 (30720) 같은 숫자

📚 기타

  • 로컬 환경에서는 이미지 업로드까지 잘 동작했는데, 배포되었을 경우에도 테스트 한번 해봐야할 것 같습니다

@hisonghy hisonghy added the ⚡ feature 새로운 기능 추가 및 수정 label Apr 17, 2025
@hisonghy hisonghy self-assigned this Apr 17, 2025
@hisonghy hisonghy requested a review from myqewr April 17, 2025 09:33
@hisonghy hisonghy force-pushed the feature/save-post-94 branch from 01b3b8b to 2b1f473 Compare April 17, 2025 09:41
@hisonghy hisonghy force-pushed the feature/save-post-94 branch from 2b1f473 to 3759ced Compare April 17, 2025 10:00
Copy link
Member

@myqewr myqewr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고 많으셨습니다!

@hisonghy hisonghy merged commit 8d1e04e into develop Apr 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚡ feature 새로운 기능 추가 및 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚡ 유저픽 게시글 저장, 등록 API 구현

2 participants